// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {
    /** 小区 */
    title: '',
    /** 楼栋 */
    building: 0,
    /** 房间 */
    room: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(ev) {
    // console.log(ev);

    /** room 房间号 floor 楼层 index 房室 */
    let room = [], floor = 0, index = 0
    for (let i = 0; i < 6; i++) {
      floor = Math.floor(Math.random() * 9) + 1
      index = Math.floor(Math.random() * 99) + 1
      index = index >= 10 ? index : '0' + index
      let item = floor.toString() + index
      room.push(item)
    }

    /** 房间号排序 */
    room.sort((a, b) => {
      return a - b
    })

    this.setData({
      title: ev.title,
      building: ev.building,
      room
    })
  }
})